//
//  showTests.swift
//  showTests
//
//  Created by 李威 on 2022/2/23.
//

import XCTest
@testable import show

class showTests: XCTestCase {

    override func setUpWithError() throws {
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }

    override func tearDownWithError() throws {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
    }

    func testExample() throws {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
        // Any test you write for XCTest can be annotated as throws and async.
        // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
        // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
    }
    
    func testCoreData_add() throws {
        var user = CoreDataUtil.getObj(oType: User.self)!
        user.id = 5
        user.userName = "xiaoli"
        user.passWord = "qwer"
        CoreDataUtil.save(model: &user)
    }
    
    func testCoreData_show () {
//        let predi = NSPredicate(format: "id=5","")
        if let list = CoreDataUtil.fetch(oType: User.self, predicates: nil) {
            for info in list {
                print("id=\(info.id)")
                print("name=\(String(describing: info.userName))")
                print("passwork=\(String(describing: info.passWord))")
            }
        }
    }

    func testPerformanceExample() throws {
        // This is an example of a performance test case.
        self.measure {
            // Put the code you want to measure the time of here.
        }
    }
}
